#define DEBUG
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

namespace ICSharpCode.TextEditor
{
	internal class InputBoxDialog : Form
	{
		private Label lblPrompt;

		public TextBox txtInput;

		private Button btnOK;

		private Button btnCancel;

		public InputBoxDialog(string prompt, string title)
			: this(prompt, title, int.MinValue, int.MinValue)
		{
		}

		public InputBoxDialog(string prompt, string title, int xPos, int yPos)
		{
			if (xPos != int.MinValue && yPos != int.MinValue)
			{
				base.StartPosition = FormStartPosition.Manual;
				base.Location = new Point(xPos, yPos);
			}
			this.InitializeComponent();
			this.lblPrompt.Text = prompt;
			this.Text = title;
			Graphics graphics = base.CreateGraphics();
			SizeF sizeF = graphics.MeasureString(prompt, this.lblPrompt.Font, this.lblPrompt.Width);
			Debug.WriteLine("Prompt Size: " + sizeF);
			if (sizeF.Height > (float)this.lblPrompt.Height)
			{
				base.Height += (int)sizeF.Height - this.lblPrompt.Height;
			}
			this.txtInput.SelectionStart = 0;
			this.txtInput.SelectionLength = this.txtInput.Text.Length;
			this.txtInput.Focus();
		}

		private void InitializeComponent()
		{
			this.lblPrompt = new System.Windows.Forms.Label();
			this.txtInput = new System.Windows.Forms.TextBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			base.SuspendLayout();
			this.lblPrompt.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
			this.lblPrompt.BackColor = System.Drawing.SystemColors.Control;
			this.lblPrompt.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
			this.lblPrompt.Location = new System.Drawing.Point(12, 20);
			this.lblPrompt.Name = "lblPrompt";
			this.lblPrompt.Size = new System.Drawing.Size(497, 50);
			this.lblPrompt.TabIndex = 0;
			this.txtInput.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
			this.txtInput.Location = new System.Drawing.Point(10, 82);
			this.txtInput.Name = "txtInput";
			this.txtInput.Size = new System.Drawing.Size(368, 23);
			this.txtInput.TabIndex = 1;
			this.btnOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
			this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.btnOK.Location = new System.Drawing.Point(349, 113);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(77, 29);
			this.btnOK.TabIndex = 2;
			this.btnOK.Text = "确认";
			this.btnCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(432, 113);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(77, 30);
			this.btnCancel.TabIndex = 3;
			this.btnCancel.Text = "取消";
			base.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 16);
			base.CancelButton = this.btnCancel;
			base.ClientSize = new System.Drawing.Size(521, 157);
			base.Controls.Add(this.txtInput);
			base.Controls.Add(this.btnCancel);
			base.Controls.Add(this.btnOK);
			base.Controls.Add(this.lblPrompt);
			base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "InputBoxDialog";
			base.ShowInTaskbar = false;
			base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			base.ResumeLayout(false);
			base.PerformLayout();
		}
	}
}
